<?php
namespace app\index\controller;

use think\Db;

class Search extends Base{
    public function index(){
        $keywords = input('keywords');
        if($keywords){
            $map['title'] = array('like', '%'.$keywords.'%');
            $seares = Db::name('article') -> where($map)-> order('id DESC') ->paginate(2);

            $this -> assign('seares', $seares);
            $this -> assign('keywords', $keywords);

        }else{
            $this -> assign('keywords', '没有关键字');
            $this -> assign('seares', null);
        }

        return $this -> fetch('search');
    }
}